package pl.net.csrv.dao.impl;

import static org.junit.Assert.*;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.junit.Ignore;
import org.junit.Test;

import pl.net.csrv.beans.User;

public class UserDaoImplTest {
	@PersistenceContext
	EntityManager em;

	public void save(User user) {
		// TODO Auto-generated method stub
	}

	@Ignore
	@Test
	public void testFindByUserId() {
		Long id = new Long(1);
		User user = em.find(User.class, id);
		assertNotNull(user);
		assertEquals(1, user.getId().longValue());
	}

	public void remove(User user) {
		// TODO Auto-generated method stub
	}

	@Test
	public void testDate() {
		DateFormat df = new SimpleDateFormat("yyyy-M-d");
		Date d;
		String s = null;
		try {
			d = df.parse("2012-11-12");
			s = df.format(d);
			System.out.println(s + " " + d.toString());
			
			d = df.parse("2012-6-12");
			s = df.format(d);
			System.out.println(s + " " + d.toString());
			
			d = df.parse("2012-12-2");
			s = df.format(d);
			System.out.println(s + " " + d.toString());
			
			d = df.parse("2012-06-2");
			s = df.format(d);
			System.out.println(s + " " + d.toString());
			
			d = df.parse("2012-6-02");
			s = df.format(d);
			System.out.println(s + " " + d.toString());

			d = df.parse("2012-06-02");
			s = df.format(d);
			System.out.println(s + " " + d.toString());

			d = df.parse("2012-6-2");
			s = df.format(d);
			System.out.println(s + " " + d.toString());
		} catch (ParseException e) {
			fail(e.getMessage());
		}
		
		
		
		
		
		
	}
}
